import { CommonEntity } from '../../../../common/entities/common.entity';
import { Column, Entity } from 'typeorm';

/** 菜单类型 */
export enum MenuType {
  /** 目录 */
  CATALOGUE = 'catalogue',
  /** 菜单 */
  MENU = 'menu',
  /** 按钮 */
  BUTTION = 'button',
}

@Entity({
  name: 'sys_menu',
  comment: '系统后台菜单表',
})
export class Menu extends CommonEntity {
  @Column({
    type: 'enum',
    enum: MenuType,
    default: MenuType.MENU,
    comment: '类型',
  })
  type: MenuType;

  @Column({
    length: 50,
    type: 'varchar',
    comment: '名称',
  })
  name: string;

  @Column({
    length: 36,
    type: 'uuid',
    default: null,
    name: 'parent_id',
    comment: '上级菜单',
  })
  parentId: string;

  @Column({
    type: 'int',
    default: 1,
    comment: '排序',
  })
  order: number;

  @Column({
    length: 200,
    type: 'varchar',
    default: null,
    comment: '图标',
  })
  icon: string;

  @Column({
    length: 100,
    type: 'varchar',
    comment: '路由地址',
  })
  path: string;

  @Column({
    length: 100,
    type: 'varchar',
    default: null,
    comment: '组件路径',
  })
  components: string;

  @Column({
    default: true,
    comment: '状态:0-禁用，1-启用',
  })
  state: boolean;

  @Column({
    default: false,
    comment: '是否缓存',
    name: 'is_cache',
  })
  isCache: boolean;

  @Column({
    default: true,
    comment: '是否显示',
    name: 'is_show',
  })
  isShow: boolean;
}
